package com.yilin.medical.utils;
import java.util.HashMap;

import android.content.Context;
import android.view.Gravity;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.RelativeLayout;
import android.widget.TextView;
import android.widget.Toast;

import com.yilin.medical.R;
import com.yilin.medical.views.JxTipDialog;

public class ToastUntil {
	private static HashMap<String, Toast> toastMap = new HashMap<String, Toast>();
    public static boolean isShow = true;
	public static void showShortToast(Context context,String text) {
		try{
            if(!isShow || JxTipDialog.isShow) return;
			if (toastMap.containsKey(text)) {
				toastMap.get(text).show();
			} else {
				Toast toast = new Toast(context);
				toast.setGravity(Gravity.FILL_HORIZONTAL + Gravity.CENTER_VERTICAL, 0, 0);
				toast.setDuration(300);
				toastMap.put(text, toast);
				LayoutInflater inflater=LayoutInflater.from(context);
				View view =  (RelativeLayout) inflater.inflate(R.layout.jx_zhagen_toast_tip, null);
				TextView content=(TextView)view.findViewById(R.id.tipContentTv);
				content.setText(text);
				toast.setView(view);
				toast.getView().setMinimumWidth(JxDeviceUtil.getScreenWidth(context));
				toast.getView().setMinimumHeight(JxDeviceUtil.getScreenHeight(context));
				toast.show();
			}	
		}catch (Exception e) {
			e.printStackTrace();
		}
			
		}
}
